package com.courseware.online.vo;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageSerializable;
import lombok.Getter;
import lombok.Setter;

import java.util.Collection;
import java.util.List;

/**
 * @author demos
 */
public class PageInfo<T> extends PageSerializable<T> {
    @Getter
    @Setter
    private int pageNum;
    @Getter
    @Setter
    private int pageSize;

    public PageInfo(List<T> list) {
        super(list);
        if (list instanceof com.github.pagehelper.Page) {
            com.github.pagehelper.Page page = (Page)list;
            this.pageNum = page.getPageNum();
            this.pageSize = page.getPageSize();
        } else if (list instanceof Collection) {
            this.pageNum = 1;
            this.pageSize = list.size();
        }
    }
}
